<template>
  <div id="app">
    <!-- <router-view></router-view> -->
    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>

<script>
export default {
  name: "App",
  provide() {
    //父组件中通过provide来提供变量，在子组件中通过inject来注入变   量。
    return {
      reload: this.reload,
    };
  },
  data() {
    return {
      isRouterAlive: true, //控制视图是否显示的变量
    };
  },
  methods: {
    reload() {
      this.isRouterAlive = false; //先关闭，
      this.$nextTick(function () {
        this.isRouterAlive = true; //再打开
      });
    },
  },
};
</script>

<style lang="less">
@import url("./assets/css/base.css");
@import url("./assets/css/iconfont.css");

body {
  height: 100%;
  width: 100%;
  background: url("./assets/bg1.jpg") no-repeat;
  background-size: cover;
}
</style>